﻿ @{
    ViewBag.Title = "SysSet";
}
@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <link href="@Url.Content("~/content/css/kingprt.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/content/css/bootstrap.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/content/css/KingcensSet.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/content/css/font-awesome.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.PrintArea.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/Base/print.js")" type="text/javascript"></script> 
    <style>
        a:link {
            color:black;
            text-decoration:none;
        }
        a:visited {
            color:black;
            text-decoration:none;
        }
        a:hover {
            color:black;
            text-decoration:underline;
        }
    </style>
}
<div class="mini-toolbar" style="padding:2px;border-top:0;border-left:0;border-right:0;"> 
    <table style="width:100%;">
        <tr>
            <td style="width:100%;">
                <a class="mini-button" name="saveCorp" iconCls="icon-save" onclick="saveData" plain="true">保存</a>
                 <span class="separator"></span>
                <a class="mini-button" iconCls="icon-close" onclick="CloseWindow" plain="true">关闭</a>
            </td>
        </tr>
    </table>       
</div>
        <div id="layout1" class="mini-layout" style="width:100%;height:100%;"  borderStyle="border:0;">
            <div region="center" showHeader = "false" >
                <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;height:100%;" plain="false"  borderStyle="border:0;">
                     <div title="商户中心">
                         <form id="form2" method="post">
                             <table  style="margin-left:20px;margin-top:20px;">
                                 <tr>
                                     <td width="80px" height ="35px" align="right">商户编号：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FNumber" id="FNumber" class="mini-textbox" style="width:280px;" required="true" value="" TabIndex="1" enabled="false"/>
                                     </td>
                                     <td width="50px" rowspan="10">&nbsp;</td>
                                     <td width="400px" rowspan="12" style="vertical-align:top;">
                                            <div style="width:100%;height:40px;line-height:40px;background-color:#ededed;font-size:16pt;text-align:center;vertical-align:middle;">
                                                扫描二维码进入此店微商城</div>
                                            <div style="width:100%;height:40px;background-color:#f3f3f3;text-align:center;vertical-align:middle;padding-top:10px;">
                                                <input type="button" class="btnPrint" style="font-size:16pt;height:30px;" value="打印二维码"/>
                                            </div>
                                            <div style="padding-top:30px;padding-left:100px;">
                                                <div class="A4_verPrint">
                                                    <iframe id="FM" name="FM" src=""  frameborder=0 width=210 height=210 marginheight=0 marginwidth=0 scrolling=no ></iframe>
                                                </div>
                                            </div>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">商户名称：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FName" id="FName" class="mini-textbox" style="width:280px;height:35px;" required="true" value="" TabIndex="2"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">所属行业：</td>
                                     <td width="280px" height ="35px">
                                         <input id="FIndustry" name="FIndustry" class="mini-combobox" style="width:280px;" textField="FName" valueField="FItemID" 
                                            url="../System/GetIndustry" value="0"  allowInput="false" showNullItem="false" enabled="false"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right"> 联 系 人：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FManager" id="FManager" class="mini-textbox" style="width:280px;height:35px;" value="" TabIndex="3" enabled="false"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">联系电话：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FTelephone" id="FTelephone" class="mini-textbox" style="width:280px;height:35px;"  value="" TabIndex="4" enabled="false"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">传真号码：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FFaxNo" id="FFaxNo" class="mini-textbox" style="width:280px;height:35px;"  value="" TabIndex="5" enabled="false"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">联系地址：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FAddress" id="FAddress" class="mini-textbox" style="width:280px;height:35px;"  value="" TabIndex="6" enabled="false"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">开户银行：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FBankName" id="FBankName" class="mini-textbox" style="width:280px;height:35px;"  value="" TabIndex="7" enabled="false"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">银行账号：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FBankNo" id="FBankNo" class="mini-textbox" style="width:280px;height:35px;"  value="" TabIndex="8" enabled="false"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">电子邮箱：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FEMail" id="FEMail" class="mini-textbox" style="width:280px;height:35px;"  value="" TabIndex="9" enabled="false"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">注册时间：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FCreateDate" id="FCreateDate" class="mini-textbox" style="width:280px;height:35px;"  value="" TabIndex="9" enabled="false"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">到期时间：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FEndTime" id="FEndTime" class="mini-textbox" style="width:280px;height:35px;"  value="" TabIndex="9" enabled="false"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">副屏广告：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FAdvUrlShop" id="FAdvUrlShop" class="mini-textbox" style="width:280px;height:35px;"  value="" TabIndex="9" enabled="false"/>
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">签到积分：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FIntForLogin" id="FIntForLogin" class="mini-textbox" style="width:280px;height:35px;"  value="" TabIndex="9" />
                                     </td>
                                 </tr>
                                 <tr>
                                     <td width="80px" height ="35px" align="right">系统版本：</td>
                                     <td width="280px" height ="35px">
                                         <input name="FWebVersion" id="FWebVersion" class="mini-textbox" style="width:280px;height:35px;"  value="" TabIndex="9" enabled="false"/>
                                     </td>
                                 </tr>
                             </table>
                         </form>
                    </div>
                    <div title="参数设置" >
                        <form id="form1" method="post">
                            <table width = "800px" height ="100%" style="margin-left:20px;">
                                <tr>
                                    <td width="80px" height ="35px" align="right">电子秤识别码：</td>
                                    <td width="200px" height ="35px" align="left">
                                        <input id="FBalanceMode" name="FBalanceMode" class="mini-spinner" changeOnMousewheel ="false" minValue="0"  maxValue="99"
                                            style="width: 200px;" TabIndex="1" showbutton="false" allowNull="true"/>                               
                                    </td>
                                    <td width="80px" height ="35px" align="right">默认门店：</td>
                                    <td width="200px" height ="35px" align="left">
                                        @Html.Partial("~/Views/Modular/LookupStockInfo.cshtml")                                  
                                    </td>
                                </tr>
                                <tr>
                                    <td width="80px" height ="35px" align="right">日结方式：</td>
                                    <td width="200px" height ="35px" align="left">
                                        <input id="FPosReckontype" name="FPosReckontype" class="mini-combobox" style="width:195px;" showNullItem="false"
                                            allowInput="false" align="left" value ="0" data ="comFPosReckontype"/>                                               
                                    </td>
                                    <td width="80px" height ="35px" align="right">库存预警：</td>
                                    <td width="200px" height ="35px" align="left">
                                        <input id="FStocklimitFlag" name="FStocklimitFlag" class="mini-combobox" style="width:195px;" showNullItem="false" 
                                            allowInput="false" align="left" value ="0" data ="comFStocklimitFlag"/>                                               
                                    </td>
                                </tr>
                                <tr>
                                    <td width="80px" height ="35px" align="right">批发单取价方式：</td>
                                    <td width="200px" height ="35px" align="left">
                                        <input id="FSelPriceType" name="FSelPriceType" class="mini-combobox" style="width:195px;" showNullItem="false"
                                            allowInput="false" align="left" value ="0" data ="dSelPriceType"/>                                               
                                    </td>
                                    <td width="80px" height ="35px" align="right">配送出库负库存方式：</td>
                                    <td width="200px" height ="35px" align="left">
                                        <input id="FDeliveryQtyType" name="FDeliveryQtyType" class="mini-combobox" style="width:195px;" showNullItem="false" 
                                            allowInput="false" align="left" value ="0" data ="comFDeliveryQtyType"/>                                               
                                    </td>
                                </tr>
                                <tr>
                                    <td width="80px" height ="35px" align="right">进销存月结方式：</td>
                                    <td width="200px" height ="35px" align="left">
                                        <input id="FReckType" name="FReckType" class="mini-combobox" style="width:195px;" showNullItem="false"
                                            allowInput="false" align="left" value ="0" data ="dReckType"/>                                               
                                    </td>
                                    <td width="80px" height ="35px" align="right">批发出库负库存方式：</td>
                                    <td width="200px" height ="35px" align="left">
                                        <input id="FSelQtyType" name="FSelQtyType" class="mini-combobox" style="width:195px;" showNullItem="false" 
                                            allowInput="false" align="left" value ="0" data ="comFDeliveryQtyType"/>                                               
                                    </td>
                                </tr>
                                <tr>
                                    <td width="80px" height ="35px" align="right">说明：</td>
                                    <td width="200px" height ="35px" align="left">
                                        月结以自然月为进销存期间，本月可以月结上个月的进销存数据。                                            
                                    </td>
                                    <td width="80px" height ="35px" align="right"></td>
                                    <td width="200px" height ="35px" align="left">
                                          
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td width="30px">
                                        <div id="FShowCs" class="mini-checkbox" style="font-size:9pt;" name="FShowCs" readonly="false" text="在商品资料显示所有颜色尺码"></div>
                                    </td>
                                    <td width="30px">
                                        &nbsp;
                                    </td>
                                    <td>
                                        <input type="button" class="btnSpell" style="font-size:12pt;height:30px;" onclick="spell()" value="生成商品拼音码"/>
                                    </td>
                                    <td width="30px">
                                    </td>
                                </tr>
                                <tr>
                                    <td width="80px" height ="35px" align="left">
                                        
                                    </td>
                                    <td width="200px" height ="35px" align="left">
                                         <div id="FTopMallFlag" class="mini-checkbox" style="font-size:9pt;" name="FTopMallFlag" readonly="false" text="商城境外商品"></div>
                                    </td>
                                    <td width="30px">
                                        &nbsp;
                                    </td>
                                    <td>
                                        
                                    </td>
                                    <td width="30px">
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td width="80px" height ="35px" align="right">小程序LOGO：</td>
                                    <td width="200px" height ="35px" align="left">
                                        <input type="text" id="FHeadUrl" name="FHeadUrl" class="mini-hidden" enabled="false" required="true" />
                                        <div style="float:left;margin-top:15px;">
                                            <img id="Image" src="~/Content/Images/NoImage.jpg" width="100" height="100" />
                                        </div>
                                        <div style="float:left;">
                                            <input id="myfile" type="file" accept=".jpg,.png">
                                            <span>图像尺寸: 100 * 100</span>
                                        </div>
                                    </td>
                                    <td align="right"></td>
                                    <td width="30px">
                                        
                                    </td>
                                </tr>
                                <tr>
                                    <td width="80px" height ="35px" align="right">
                                        @*小程序参数：*@
                                    </td>
                                    <td width="200px" height ="35px" align="left">
                                        @*@Html.Partial("~/Views/Modular/LookupXcxApp.cshtml")*@
                                    </td>
                                    <td width="30px">
                                        &nbsp;
                                    </td>
                                    <td>

                                    </td>
                                    <td width="30px">
                                        &nbsp;
                                    </td>
                                </tr>
                            </table>
                            <div><img id="QCodeImg" src="" /></div>
                        </form>
                    </div>
                    <div title="短信设置">
                        <form id="form3" method="post">
                            <div title="短信帐户设置" class="mini-panel" style="width:100%;height:160px;top:10px" buttons="">
                                <table width = "500px">
                                    <tr>
                                        <td width ="80px" height ="35px" align="right">商户ID：</td>
                                        <td width ="350px" height ="35px"> 
                                            <input name="FSmsUserID" class="mini-textbox" style="width:260px;" enabled = "false" /></td>
                                    </tr>
                                    <tr>
                                        <td width ="80px" height ="35px" align="right">帐号：</td>
                                        <td width ="350px" height ="35px"> 
                                            <input name="FSmsUserName" class="mini-textbox" style="width:260px;"enabled = "false"/></td>
                                    </tr>
                                    <tr>
                                        <td width ="80px" height ="35px" align="right">密码：</td>
                                        <td width ="350px" height ="35px"> 
                                            <input name="FSmsUserPsd" class="mini-textbox" style="width:260px;"enabled = "false"/></td>
                                    </tr>
                                </table>
                            </div>

                            <div title="会员积分变动短信设置" class="mini-panel" style="width:100%;height:120px;" buttons="">
                                <table  style="margin-left:20px;margin-top:20px;">
                                    <tr>
                                        <td width="80px" height ="35px" align="right">是否发送：</td>
                                        <td width="350px" height ="35px">
                                            <input id="FPointMsgFlag" name="FPointMsgFlag" class="mini-combobox" style="width:260px;" showNullItem="false"
                                            allowInput="false" align="left" value ="0" data ="dPointMsgFlag"/>      
                                        </td>
                                    </tr>
                                </table> 
                            </div>  
                            
                            <div title="会员余额及次卡变动短信设置" class="mini-panel" style="width:100%;height:120px;" buttons="">
                                <table  style="margin-left:20px;margin-top:20px;">
                                    <tr>
                                        <td width="80px" height ="35px" align="right">是否发送：</td>
                                        <td width="350px" height ="35px">
                                            <input id="FAmountMsgFlag" name="FAmountMsgFlag" class="mini-combobox" style="width:260px;" showNullItem="false"
                                            allowInput="false" align="left" value ="0" data ="dPointMsgFlag"/>      
                                        </td>
                                    </tr>
                                </table> 
                            </div>                                                       
                        </form>
                    </div>      
                    <div title="电商设置">
                        <form id="form4" method="post">
                            <table width = "500px">
                                <tr>
                                    <td width ="150px" height ="35px" align="right">电商虚拟库存量：</td>
                                    <td width ="230px" height ="35px">
                                        <input id="FVirtualInv" name="FVirtualInv" class="mini-spinner " maxlength="50" style="width:220px;" minValue="0"
                                         maxValue="9999999" TabIndex="11" showbutton="false" allowNull="true" changeOnMousewheel="false" format="n" />
                                    </td>
                                    <td width ="200px" height ="35px"> 
                                        提示：填0表示取当前结存为电商库存量(仅适用于公众号电商）
                                    </td>
                                </tr>
                                <tr>
                                    <td width ="150px" height ="35px" align="right">小程序类型：</td>
                                    <td width ="230px" height ="35px">    
                                        <input id="FChainFlag" name="FChainFlag" class="mini-combobox" style="width:220px;" 
                                            showNullItem="false" allowInput="false" align="left" value ="0" data ="comFChainFlag"/>                                        
                                    </td>
                                    <td width ="200px" height ="35px">                                        
                                    </td>
                                </tr>
                                <tr>
                                    <td width ="150px" height ="35px" align="right"></td>
                                    <td width ="230px" height ="35px">
                                    </td>
                                    <td width ="200px" height ="35px">                                        
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>                                      
                   <div title="系统激活" style="width:100%;height:100%;overflow:hidden;">
                       <table width = "400px" style="margin-left:20px;">
                            <tr>
                                <td width="100px" height ="35px" align="right" class="fonthsx">有效期至：</td>
                                <td>
                                    <div id="EndTimes" name="EndTimes" class="fonthsx"></div>
                                </td>
                            </tr>
                           <tr>
                               <td height="50px" align="right" class="fonthsx">激活码：</td>
                               <td>
                                   <input id="ActionCode"  type="text" class="form-control" placeholder="请输入激活码">
                               </td>
                               <td style="padding-left:5px;">
                                   <input type="button" id="ActionBtn" value="开始激活"  class="btn btn-default" style="width:90px;"/>
                               </td>
                           </tr>
                       </table>
                    </div>
                </div>
            </div>
        </div>

    <input type="hidden" value="500" id="posPrice" />
<script>
    var comType = [{"id":"0","text":"前台"},
                    { "id": "500", "text": "前台+后台管理" },
                   { "id": "1000", "text": "微商城+后台管理" },
                { "id": "1500", "text": "前台+微商城+后台管理" }];
    var comTime = [{ "id": "1", "text": "一年" },
                    { "id": "2", "text": "两年" },
                    { "id": "3", "text": "三年" },
                    { "id": "5", "text": "五年" }];

    var dPointMsgFlag = [{ "id": "0", "text": "不发送" },
                { "id": "1", "text": "自动发送" }];

    var comFPosReckontype = [{ "id": "0", "text": "前台或后台手动日结" },
                        { "id": "1", "text": "前台交班后自动日结" } ]

    var comFStocklimitFlag = [{ "id": "0", "text": "不显示库存预警" },
                        { "id": "1", "text": "库存预警" }]

    var dSelPriceType = [{ "id": "0", "text": "仅商品资料批发价" },
                        { "id": "1", "text": "最后一次批发价" },
                        { "id": "2", "text": "价格方案批发价" }]

    var comFDeliveryQtyType = [{ "id": "0", "text": "允许负库存审核出库" },
                        { "id": "1", "text": "不允许负库存审核出库" }]
    
    var dReckType = [{ "id": "0", "text": "不进行月结转" },
                        { "id": "1", "text": "人工进行月结转" },
                        { "id": "2", "text": "系统自动进行月结转" }]

    var comFChainFlag = [{ "id": "0", "text": "独立商品及装修小程序" },
                    { "id": "1", "text": "共享总店商品及装修小程序" }]
    
    var selectinfo = {};
    var iNum = 1;
    mini.parse();

    $(function () {
        $("#mpay").hide();
        load();
        $(".itemtag").bind("click", LIItemClick);
        $(".mini-textbox").css("display", "inline");
        $(".btnPrint").click(function () {
            $(".A4_verPrint").printArea();
        });
        $("#ActionBtn").bind("click", Action);
        selectinfo["LI001"] = 500;
        selectinfo["LI002"] = 0;
        selectinfo["li003"] = 0;
        $("#FM").attr("src", "GetQCode?mSystemAppID=" + encodeURIComponent(parent.window.getSystemAppID()));

        $("#myfile").change(function () {
            var formData = new FormData();
            formData.append("myfile", document.getElementById('myfile').files[0]);
            formData.append("mSystemAppID", parent.window.getSystemAppID());
            $.ajax({
                url: "/Upload/UploadFile",
                type: "post",
                data: formData,
                contentType: false,
                processData: false,
                success: function (res) {
                    if (res.status == 1) {
                        $("#Image").attr("src", res.path);
                        mini.get("FHeadUrl").setValue(res.logoUrl);
                    }
                }
            });
        });

    });

    function load() {
        $.post("GetCorpDefault", { mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            var form = new mini.Form("form2");
            var mdata = mini.decode(data);
            form.setData(mdata.data[0]);
            mini.getbyName("FVirtualInv").setValue(mdata.data[0].FVirtualInv);
            mini.getbyName("FChainFlag").setValue(mdata.data[0].FChainFlag);
            $("#EndTime").html(mdata.data[0].FEndTime.format("yyyy-MM-dd hh:mm:ss"));
            $("#EndTimes").html(mdata.data[0].FEndTime.format("yyyy-MM-dd hh:mm:ss"));
            mini.getbyName("FEndTime").setValue(mdata.data[0].FEndTime.format("yyyy-MM-dd HH:mm:ss"));
            mini.getbyName("FCreateDate").setValue(mdata.data[0].FCreateDate.format("yyyy-MM-dd HH:mm:ss"));
            mini.getbyName("FStockID").setEnabled(false);
            if (mdata.data[0].FItemID == 1) mini.getbyName("FTelephone").setEnabled(true);
            if (mdata.data.length > 0) {
                mini.getbyName("FStockID").setValue(mdata.data[0].FStockID);
                mini.getbyName("FStockID").setText(mdata.data[0].FStockNumber);
                mini.getbyName("FStockName").setValue(mdata.data[0].FStockName);
            }
            if (mdata.bbData.length > 0) {
                mini.get("FTopMallFlag").setChecked(mdata.bbData[0].FTopMallFlag);
                mini.get("FShowCs").setChecked(mdata.bbData[0].FShowCs);
                mini.get("FPosReckontype").setValue(mdata.bbData[0].FPosReckontype);
                mini.get("FStocklimitFlag").setValue(mdata.bbData[0].FStockLimitFlag);
                mini.get("FDeliveryQtyType").setValue(mdata.bbData[0].FDeliveryQtyType);
                mini.get("FSelQtyType").setValue(mdata.bbData[0].FSelQtyType);
                mini.getbyName("FSmsUserID").setValue(mdata.bbData[0].FSmsUserID);
                mini.getbyName("FSmsUserName").setValue(mdata.bbData[0].FSmsUserName);
                mini.getbyName("FSmsUserPsd").setValue(mdata.bbData[0].FSmsUserPsd);
                mini.getbyName("FPointMsgFlag").setValue(mdata.bbData[0].FPointMsgFlag);
                mini.getbyName("FAmountMsgFlag").setValue(mdata.bbData[0].FAmountMsgFlag);
                mini.getbyName("FBalanceMode").setValue(mdata.bbData[0].FBalanceMode);
                mini.get("FSelPriceType").setValue(mdata.bbData[0].FSelPriceType);
                mini.get("FReckType").setValue(mdata.bbData[0].FReckType);
                if (mdata.bbData[0].FHeadUrl != "") {
                    mini.get("FHeadUrl").setValue(mdata.bbData[0].FHeadUrl);
                    $("#Image").attr('src', mdata.bbData[0].FHeadUrl);
                }
            }
        });
        modifyCorp(true);
        modifyDefault();
    }

    function BillStart() {
        mini.open({
            url: "../System/WXPay?pos="+selectinfo["LI001"]+"&WX="+selectinfo["LI003"]+"&Num="+iNum+"&BServer="+selectinfo['LI002'],
            title: "微信支付", width: 600, height: 530,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = {};
                data.AppID = parent.window.getSystemAppID();
                data.selectinfo = selectinfo;
                data.iNum = iNum;
                iframe.contentWindow.SetData(data);
            }
        });
        //$("#mpay").show();
        //$("#FMPAY").attr("src", "CustomPay?pos="+selectinfo["LI001"]+"&WX="+selectinfo["LI003"]+"&Num="+iNum);
    }

    function LoadListData() {
        var json = "[{";
        json = json + "'search':" + "''";
        json = json + ",'mSystemAppID':" + "'" + parent.window.getSystemAppID() + "'}]";
        var grid = mini.get("datagrid1");
        grid.load({ mjson: json });
    }

    function saveData() {
        saveDefault();
        saveCorp();
    }

    function saveDefault() {
        var form1 = new mini.Form("#form1");
        var data1 = form1.getData(true, false);
        if (data1.FStockID == "") {
            mini.alert("默认门店未选择");
            return;
        }
        var sVirtualInv = mini.getbyName("FVirtualInv").getValue();
        var sChainFlag = mini.getbyName("FChainFlag").getValue();
        var form3 = new mini.Form("#form3");
        var data3 = form3.getData(true, false);
        var json3 = mini.encode(data3);
        var mjson = "{'FStockID':'" + data1.FStockID
            + "','FPosReckontype':'" + data1.FPosReckontype
            + "','FTopMallFlag':'" + data1.FTopMallFlag
            + "','FSmsUserID':'" + data3.FSmsUserID
            + "','FSmsUserName':'" + data3.FSmsUserName
            + "','FSmsUserPsd':'" + data3.FSmsUserPsd
            + "','FPointMsgFlag':'" + data3.FPointMsgFlag
            + "','FAmountMsgFlag':'" + data3.FAmountMsgFlag
            + "','FStocklimitFlag':'" + data1.FStocklimitFlag
            + "','FDeliveryQtyType':'" + data1.FDeliveryQtyType
            + "','FSelQtyType':'" + data1.FSelQtyType
            + "','FSelPriceType':'" + data1.FSelPriceType
            + "','FReckType':'" + data1.FReckType
            + "','FVirtualInv':'" + sVirtualInv
            + "','FChainFlag':'" + sChainFlag
            + "','FBalanceMode':'" + data1.FBalanceMode
            + "','FHeadUrl':'" + mini.get("FHeadUrl").getValue()
            + "','FShowCs':'" + data1.FShowCs
            + "','FAppFItemID':'" + data1.FAppID
            + "'}";
        $.post("saveDefault", { json: mjson, mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            var ret = mini.decode(data);
            if (ret.status == "1")
                mini.showTips({ content: ret.msg, state: "success", x: "center", y: "top", timeout: 3000 });
            else
                mini.showTips({ content: ret.error, state: "danger", x: "center", y: "top", timeout: 3000 });
        });
    }

    function saveCorp() {
        var form = new mini.Form("#form2");
        var data = form.getData(true, false);
        var datajson = mini.encode(data);
        $.post("saveCorp", { json: datajson, mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            var ret = mini.decode(data);
            if (ret.status == "1")
                mini.showTips({ content: ret.msg, state: "success", x: "center", y: "top", timeout: 3000 });
            else
                mini.showTips({ content: ret.error, state: "danger", x: "center", y: "top", timeout: 3000 });
        });
        //modifyCorp(false);
    }

    function modifyCorp(Enabled) {
        mini.getbyName("FName").setEnabled(Enabled);
        mini.getbyName("FManager").setEnabled(Enabled);
        mini.getbyName("FFaxNo").setEnabled(Enabled);
        mini.getbyName("FAddress").setEnabled(Enabled);
        mini.getbyName("FBankName").setEnabled(Enabled);
        mini.getbyName("FBankNo").setEnabled(Enabled);
        mini.getbyName("FEMail").setEnabled(Enabled);
        mini.getbyName("saveCorp").setEnabled(true);
        mini.getbyName("FIndustry").setEnabled(Enabled);
        mini.getbyName("FAdvUrlShop").setEnabled(Enabled);
    }

    function modifyDefault(Enabled) {
        //if (Enabled) {
        //    mini.getbyName("save").enable();
        //}
        //else {
        //    mini.getbyName("saveCorp").disable();
        //}
    }

    function GetQCode() {
        mini.open({
            url: "../System/QCode",
            title: "公司二维码", width: 500, height: 500,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = parent.window.getSystemAppID();
                iframe.contentWindow.SetData(data);
            }
        });

    }

    function spell() {
        mini.confirm("确定要重新生成商品的拼音简码吗？", "提示",
            function (action) {
                if (action == "ok") {
                    mini.mask({
                        el: document.body,
                        cls: 'mini-mask-loading',
                        html: '正在生成商品拼音码...'
                    });
                    $.post("../System/GenSpell", { json: parent.window.getSystemAppID() }, function (data) {
                        mini.unmask(document.body);
                        var ret = mini.decode(data);
                        if (ret.status == 1)
                            mini.showTips({ content: '生成拼音完成', state: "success", x: "center", y: "top", timeout: 3000 });
                        else
                            mini.showTips({ content: ret.error, state: "danger", x: "center", y: "top", timeout: 3000 });
                    });
                }
            });
    }

    function TermList() {
        var grid = mini.get("termgrid");
        grid.load({FSystemAppID:parent.window.getSystemAppID()});
    }

    var Action = function () {
        if ($("#ActionCode").val().length == "") {
            mini.alert("激活码未输入");
            return;
        }
        mini.confirm("确定要使用此激活码？", "提示",
        function (action) {
            if (action == "ok") {
                $("#ActionBtn").addClass("disabled");
                var jsonstr = '[{"AcCode":"' + $("#ActionCode").val() + '","mSystemAppID":"' + parent.window.getSystemAppID() + '"}]';
                $.post("ActionCode", { mjson: jsonstr }, function (data) {
                    var ret = mini.decode(data);
                    if (ret.status == 1) {
                        mini.alert("激活成功");
                        $("#ActionCode").val('');
                        load();
                    }
                    else {
                        mini.alert("激活失败," + ret.error);
                    }
                })
                .success(function () { })
                .error(function () { })
                .complete(function () { $("#ActionBtn").removeClass("disabled");  });
            }
        });
    }

    var LIItemClick = function () {        
        var name = $(this).attr("name");
        if (name == 'LI003') {
            if (typeof ($('[name="' + name + '"]').attr("select")) == "undefined") {
                $(this).attr("select", true);
                selectinfo[name] = $(this).attr("tag");
            }
            else {
                $('[name="' + name + '"]').removeAttr("select");
                selectinfo[name] = 0;
            }
        }
        else
        {
            $('[name="' + name + '"]').removeAttr("select");
            $(this).attr("select", true);
            if (name == "iNum") { iNum = $(this).attr("tag"); } else {
                selectinfo[name] = parseFloat($(this).attr("tag")) * parseFloat($("#posPrice").val());
            }
        }
        ComputeMoney();
    }
    var ComputeMoney = function () {
        var Money = 0;
        var pos = 0;
        pos = parseInt(selectinfo['LI001']);
        if (selectinfo['LI003'] == undefined) selectinfo['LI003'] = 0;
        Money = (pos + parseInt(selectinfo['LI002']) + parseInt(selectinfo['LI003'])) * iNum;
        $("#UnitPrice").html(Money);
    }

</script>